package com.analysis.model;

import lombok.Data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class AnalysisResult {
    private List<ClassDifference> differences = new ArrayList<>();
    private String oldJarName;
    private String newJarName;
    private long analysisTime;
    private int totalClasses;
    private int modifiedClasses;
    private int addedClasses;
    private int deletedClasses;
    private Map<String, List<String>> affectedApis = new HashMap<>();

    public List<ClassDifference> getClassDifferences() {
        return differences;
    }

    public void setClassDifferences(List<ClassDifference> differences) {
        this.differences = differences;
    }

    public Map<String, List<String>> getAffectedApis() {
        // 收集所有受影响的API
        Map<String, List<String>> apis = new HashMap<>();
        for (ClassDifference diff : differences) {
            if (diff.getAffectedApis() != null && !diff.getAffectedApis().isEmpty()) {
                apis.put(diff.getClassName(), diff.getAffectedApis());
            }
        }
        return apis;
    }

    public void setAffectedApis(Map<String, List<String>> affectedApis) {
        this.affectedApis = affectedApis;
    }
}
